package com.ayz.gateway.server.service;


import com.ayz.gateway.api.request.CheckServer;
import com.ayz.gateway.api.response.GatewayCommonResult;
import com.ayz.gateway.api.server.CheckServerServiceGrpc;
import com.ayz.gateway.common.result.ResponseCode;
import io.grpc.stub.StreamObserver;

/**
 * @ClassName ServerCheckServiceImpl
 * @Description TODO: 检查服务端是否能够双向导通
 * @Author 快乐的星球
 * @Date 2023/5/21 20:41
 * @Version 1.0
 **/
public class ServerCheckServiceImpl extends CheckServerServiceGrpc.CheckServerServiceImplBase {

    @Override
    public void checkServer(CheckServer.CheckServerRequest request, StreamObserver<GatewayCommonResult.GatewayResult> responseObserver) {
        //1:准备一个响应结果
        GatewayCommonResult.GatewayResult.Builder builder = GatewayCommonResult.GatewayResult.newBuilder();
        builder.setCode(ResponseCode.COMMON_SUCCESS);
        GatewayCommonResult.GatewayResult gatewayResult = builder.build();
        //2: 返回响应
        responseObserver.onNext(gatewayResult);
        responseObserver.onCompleted();
    }
}
